package www.openteam.com.presenter.business;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.AddDeliverNote;
import www.openteam.com.bean.ShipBus;
import www.openteam.com.bean.ShipBusList;
import www.openteam.com.bean.UpdateInfo;
import www.openteam.com.contract.business.LoadListContract;
import www.openteam.com.model.business.LoadListModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.LoadingListFragment;

/**
 * Created by Administrator on 2019-08-16.
 */

public class LoadListPresenter extends BasePresenter<LoadingListFragment> implements
        LoadListContract.LoadListPrst {

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new LoadListModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("LoadListPresenter", models[0]);
        return hashMap;
    }

    @Override
    public void getShipBus(String rdsno) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).getShipBus(rdsno, new LoadListModel.ShipBustListener() {
            @Override
            public void success(ShipBus shipBus) {
                getIView().getShioBusSucces(shipBus);
            }

            @Override
            public void fail(String msg) {
                getIView().getShipBusFail(msg);
            }
        });
    }

    @Override
    public void getShipBusList(String zbid) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).getShipBusList(zbid, new LoadListModel.ShipBustListListener() {
                    @Override
                    public void success(ShipBusList shipBusList) {
                        getIView().getShioBusListSucces(shipBusList);
                    }

                    @Override
                    public void fail(String msg) {
                        getIView().getShipBusListFail(msg);
                    }
                }
        );
    }

    @Override
    public void addDeliverNote(String rdsno) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).addDeliverNote(rdsno, new LoadListModel.AddDeliverNoteListener() {
            @Override
            public void success(AddDeliverNote addDeliverNote) {
                getIView().addDeliverNoteSucces(addDeliverNote);
            }

            @Override
            public void fail(String msg) {
                getIView().addDeliverNoteFail(msg);
            }
        });
    }

    @Override
    public void insertDlertNote(String group, String old_group) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).insertDeliverNote(group, old_group, new LoadListModel.InsertDeliverNoteListener() {
            @Override
            public void success(UpdateInfo info) {
                getIView().updateDlertNoteSuccess(info);
            }

            @Override
            public void fail(String msg) {
                getIView().updateDlertNoteFail(msg);
            }
        });
    }

    @Override
    public void deleteDeliverNote(String id) {

    }

    @Override
    public void deleteLoadingListNote(String id) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).deleteLoadList(id, new LoadListModel.DeleteLoadListListener() {
            @Override
            public void success(UpdateInfo info) {
                getIView().deleteLoadingListNoteSuccess(info);
            }

            @Override
            public void fail(String msg) {
                getIView().deleteLoadingListNoteFail(msg);
            }
        });
    }

    @Override
    public void audit(String id, String checker, String checkDate) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).audit(id, checker, checkDate, new LoadListModel.AuditListener() {
            @Override
            public void success(UpdateInfo info) {
                getIView().auditSuccess(info);
            }

            @Override
            public void fail(String msg) {
                getIView().auditFail(msg);
            }
        });
    }

    @Override
    public void unaudit(String id) {
        ((LoadListModel) getiModelMap().get("LoadListPresenter")).unaudit(id, new LoadListModel.UnAuditListener() {
            @Override
            public void success(UpdateInfo info) {
                getIView().unauditSuccess(info);
            }

            @Override
            public void fail(String msg) {
                getIView().unauditFail(msg);
            }
        });
    }
}
